#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;

void Sort(int A[], int N)
{
int i, j, c;
for(int i = 0; i < N-1; i++) {
   for ( j = N-2; j >= i ; j-- )
     if ( A[j] > A[j+1] )
      {
      c= A[j];
      A[j]=A[j+1];
      A[j+1]=c;
      }
}
}

int main()
{
ifstream Fin;
int i, j, c, N;
int A[5000];
unsigned int start, finish, tw;

Fin.open ( "m1_sorted.txt" );
N = 0;
while ( !Fin.eof() )
  if ( Fin >> A[N] ) N ++;
start = clock();
Sort(A,N);
finish = clock();
tw = finish - start;
cout<<"Time sorted m1_sorted.txt  " << tw << " milliseconds \n";
Fin.close();

Fin.open ( "m2_reverse.txt" );
N=0;
while ( !Fin.eof() )
  if ( Fin >> A[N] ) N ++;
start = clock();
Sort(A,N);
finish = clock();
tw = finish - start;
cout<<"Time sorted m2_reverse.txt  " << tw << " milliseconds \n";
Fin.close();

Fin.open ( "m3_shuffle.txt" );
N=0;
while ( !Fin.eof() )
  if ( Fin >> A[N] ) N ++;
start = clock();
Sort(A,N);
finish = clock();
tw = finish - start;
cout<<"Time sorted m3_shuffle.txt  " << tw << " milliseconds \n";
Fin.close();
}



